import Vue from 'vue';
import VueModal from './modal.vue';

const Modal = Vue.extend(VueModal);
/**
 * modal - options
 * 
 * @param title 标题
 * @param content 内容
 * @param confirmText 确定
 * @param cancelText 取消
 * @param confirmFunction 确定回调 
 * @param cancelFunction 取消回调
 */
const modal = (options) => {
    // 实例
    const instance = new Modal();
    instance.vm = instance.$mount();
    document.body.appendChild(instance.vm.$el);
    // 赋值
    instance.title = options.title;
    instance.content = options.content;
    instance.confirmText = options.confirmText;
    instance.cancelText = options.cancelText;
    instance.confirmFunction = options.confirmFunction;
    instance.cancelFunction = options.cancelFunction;
}
// 挂载到全局
// toastMessage.install = (Vue) => {
//     Vue.prototype.$modal = modal;
// }
export default modal